function saveFigure( fig, path, name, portraitTf )
%SAVEFIGURE Don't include the extension in name!

% Remove illigal characters..
name([find(name=='/') find(name==';') find(name=='\') find(name=='?') find(name=='*') ]) = '_';
disp(['Exporting to file: ' name]);

saveas(fig, [path name '.fig'])
set(fig, 'PaperUnits', 'centimeters');
set(fig, 'PaperType', 'A4');
if exist('portraitTf') && portraitTf
    set(fig, 'PaperOrientation', 'portrait');
    set(fig, 'PaperPositionMode', 'manual');
    set(fig, 'PaperPosition', [0.6 0.6 19.7 28.4]);
else
    set(fig, 'PaperOrientation', 'landscape');
    set(fig, 'PaperPositionMode', 'manual');
    set(fig, 'PaperPosition', [0.6 0.6 28.4 19.7]);
end

print(['-f' num2str(fig)], [path name '.eps'], '-depsc', '-r600');
print(['-f' num2str(fig)], [path name '.png'], '-dpng', '-r600');
print(['-f' num2str(fig)], [path name '.pdf'], '-dpdf', '-r600');

end